package de.fstyle.android.worldcanvas;

import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.TransitionDrawable;

public class BGColorTransitionDrawable extends TransitionDrawable {
	
	public static final int DEFAULT_INTERVAL = 500;
	
	private int interval;

	public BGColorTransitionDrawable(Drawable[] layers) {
		this(layers, DEFAULT_INTERVAL);
	}

	public BGColorTransitionDrawable(Drawable[] layers, int interval) {
		super(layers);
		this.interval = interval;
		initVars();
	}

	private void initVars() {
		setCrossFadeEnabled(true);
		setId(0, 0);
		setId(1, 1);
	}

	public void changeColor(int color) {
		setDrawableByLayerId(0, getDrawable(1));
		setDrawableByLayerId(1, new ColorDrawable(color));
		startTransition(this.interval);
	}
}